/* GUI CONVERTED from rsscmt.p (converter v1.75) Tue Nov  7 07:30:23 2000 */
/* rsscmt.p - Release Management Supplier Schedules                         */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.             */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                       */
/* REVISION: 7.3      LAST MODIFIED: 12/10/92    BY: WUG *G462**/
/* REVISION: 7.3      LAST MODIFIED: 06/10/93    BY: WUG *GB98**/
/* REVISION: 7.3      LAST MODIFIED: 08/23/94    BY: dpm *GL44**/
/* Oracle changes (share-locks)      09/13/94    BY: rwl *GM48**/
/* REVISION: 7.3      LAST MODIFIED: 09/21/94    BY: ljm *GM77**/
/* REVISION: 7.3      LAST MODIFIED: 11/07/94    BY: ljm *GO15**/
/* REVISION: 7.3      LAST MODIFIED: 02/16/95    BY: rxm *G0D5**/
/* REVISION: 7.3      LAST MODIFIED: 04/09/95    BY: vrn *G0MD**/
/* REVISION: 7.3      LAST MODIFIED: 03/20/96    BY: kjm *G1R2**/
/* REVISION: 7.4      LAST MODIFIED: 08/25/97   BY: Todd Runkle *H1DK*      */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane        */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan       */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan       */
/* REVISION: 9.0      LAST MODIFIED: 02/24/99   BY: *J3BR* Anup Pereira     */
/* REVISION: 9.0      LAST MODIFIED: 03/13/99   BY: *M0BD* Alfred Tan       */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown       */

         /* SUPPLIER CALENDAR MAINT */

/*GB98*/ {mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rsscmt_p_1 "Sunday"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsscmt_p_2 "Wednesday"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsscmt_p_3 "Thursday"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsscmt_p_6 "Supplier"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsscmt_p_7 "Tuesday"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsscmt_p_8 "Saturday"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsscmt_p_9 "Friday"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsscmt_p_11 "Monday"
/* MaxLen: Comment: */

&SCOPED-DEFINE rsscmt_p_15 "Description"
/* MaxLen: Comment: */

/*N0RT***
 *
 * &SCOPED-DEFINE rsscmt_p_4 "Work Day"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsscmt_p_5 "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,
 * Saturday"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsscmt_p_10 "    Hours"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsscmt_p_12 " Operating Day Hour Exceptions "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsscmt_p_13 " Non-Operating Days "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rsscmt_p_14 " Supplier Calendar "
 * /* MaxLen: Comment: */
 ***********************************/

/* ********** End Translatable Strings Definitions ********* */

         define variable del-yn like mfc_logical initial no.
         define variable daylabel as character format "x(10)".
/*N0RT*/ define variable lit-text as character format "x(12)" extent 2 no-undo.
/*N0RT*/ define variable days     as character format "x(80)" no-undo.

/*G0D5*/ define buffer poddet for pod_det.

/*N0RT*/ lit-text[1] = getTermLabel("WORK_DAY",12).
/*N0RT*/ lit-text[2] = getTermLabel("HOURS",12).
/*N0RT*/ days = getTermLabel("SUNDAY",10) + ",".
/*N0RT*/ days = days + getTermLabel("MONDAY",10) + ",".
/*N0RT*/ days = days + getTermLabel("TUESDAY",10) + ",".
/*N0RT*/ days = days + getTermLabel("WEDNESDAY",10) + ",".
/*N0RT*/ days = days + getTermLabel("THURSDAY",10) + ",".
/*N0RT*/ days = days + getTermLabel("FRIDAY",10) + ",".
/*N0RT*/ days = days + getTermLabel("SATURDAY",10).

/*N0RT***
 *         form
 *           shop_site  colon 25 label {&rsscmt_p_6} ad_name no-label
 *           skip(1)
 * /*GO15*/    {&rsscmt_p_4}  at 25   {&rsscmt_p_10} /*V8! at 40 */ skip
 *           shop_wdays[1]  label {&rsscmt_p_1}    colon 25 space(8)
 *           shop_hours[1]  no-label
 *           shop_wdays[2]  label   {&rsscmt_p_11}   colon 25 space(8)
 *           shop_hours[2]  no-label
 *           shop_wdays[3]  label   {&rsscmt_p_7}    colon 25 space(8)
 *           shop_hours[3]  no-label
 *           shop_wdays[4]  label   {&rsscmt_p_2}    colon 25 space(8)
 *           shop_hours[4]  no-label
 *           shop_wdays[5]  label   {&rsscmt_p_3}    colon 25 space(8)
 *           shop_hours[5]  no-label
 *           shop_wdays[6]  label   {&rsscmt_p_9}    colon 25 space(8)
 *           shop_hours[6]  no-label
 *           shop_wdays[7]  label   {&rsscmt_p_8}    colon 25 space(8)
 *           shop_hours[7]  no-label
 ***********/
/*N0RT*/ /* Redid the form definition */
         
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
            
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
shop_site   colon 25 label {&rsscmt_p_6} ad_name no-label
            skip(1)
            lit-text[1]   at 27    no-label
            lit-text[2]   at 40    no-label
            shop_wdays[1] colon 25 label {&rsscmt_p_1}
            shop_hours[1] at 40    no-label
            shop_wdays[2] colon 25 label {&rsscmt_p_11}
            shop_hours[2] at 40    no-label
            shop_wdays[3] colon 25 label {&rsscmt_p_7}
            shop_hours[3] at 40    no-label
            shop_wdays[4] colon 25 label {&rsscmt_p_2}
            shop_hours[4] at 40    no-label
            shop_wdays[5] colon 25 label {&rsscmt_p_3}
            shop_hours[5] at 40    no-label
            shop_wdays[6] colon 25 label {&rsscmt_p_9}
            shop_hours[6] at 40    no-label
            shop_wdays[7] colon 25 label {&rsscmt_p_8}
            shop_hours[7] at 40    no-label
/*G0MD*  with frame a side-labels width 80 title "Supplier Calendar" attr-space.*/
/*G0MD*/  SKIP(.4)  /*GUI*/
with frame a side-labels width 80
/*G0MD*/  attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = (getFrameTitle("SUPPLIER_CALENDAR",25)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



         /* SET EXTERNAL LABELS */
         setFrameLabels(frame a:handle).

         FORM /*GUI*/ 
            
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
cal_ref        colon 25
            cal_start      colon 25 skip (1)
            cal_end        colon 25
            cal_hours
          SKIP(.4)  /*GUI*/
with frame b width 80 attr-space side-labels
/*G0MD*  title "Operating Day Hour Exceptions". */
/*G0MD*/  NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-b-title AS CHARACTER.
 F-b-title = (getFrameTitle("OPERATING_DAY_HOUR_EXCEPTIONS",41)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame b =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame b + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame b =
  FRAME b:HEIGHT-PIXELS - RECT-FRAME:Y in frame b - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME b = FRAME b:WIDTH-CHARS - .5. /*GUI*/


         /* SET EXTERNAL LABELS */
         setFrameLabels(frame b:handle).

         FORM /*GUI*/ 
            
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
hd_date              colon 25
            skip(1)
            hd_desc              colon 25 label {&rsscmt_p_15}
/*GM77*/       skip space(2) daylabel   
          SKIP(.4)  /*GUI*/
with frame c width 80 attr-space side-labels
/*G0MD*  title "Non-Operating Days". */
/*G0MD*/  NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-c-title AS CHARACTER.
 F-c-title = (getFrameTitle("NON-OPERATING_DAYS",26)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame c = F-c-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame c =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame c + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame c =
  FRAME c:HEIGHT-PIXELS - RECT-FRAME:Y in frame c - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME c = FRAME c:WIDTH-CHARS - .5. /*GUI*/


         /* SET EXTERNAL LABELS */
         setFrameLabels(frame c:handle).

         mainloop:
         repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


            do transaction:
/*GUI*/ if global-beam-me-up then undo, leave.


               prompt-for shop_site with frame a editing:

                 {mfnp01.i ls_mstr shop_site ls_addr ""suppcal"" ls_type ls_type}

                 if frame-field = "shop_site" then
                    global_addr = frame-value.
                 if recno <> ? then do:
                    find shop_cal where shop_site eq ls_addr
                    and shop_wkctr = "" and shop_mch = "" no-lock no-error.
/*GL44*/            if available shop_cal then do:
                       find ad_mstr no-lock where ad_addr = shop_site no-error.
                       display
                          shop_site
                          ad_name when (available ad_mstr)
                          "" when (not available ad_mstr) @ ad_name
                          shop_wdays
                          shop_hours
                       with frame a.
/*GL44*/            end.
                 end.

               end. /* prompt-for editing */

/*GB98*/       /*USE VD_MSTR INSTEAD OF AD_MSTR AND USE CORRECT MESSAGE #*/
               find vd_mstr where vd_addr = input frame a shop_site
               no-lock no-error.

               if not available vd_mstr then do:
                  {mfmsg.i 2 3}
                  undo , retry.
               end.

               find ad_mstr where ad_addr = vd_addr no-lock.

               find shop_cal
               where shop_site = input frame a shop_site
               and shop_wkctr = "" and shop_mch = ""
               exclusive-lock no-error.

               if not available shop_cal then do with frame a:
                  {mfmsg.i 1 1}

                  find ls_mstr
                  where ls_addr = input shop_site
                  and ls_type = "suppcal"
                  no-lock no-error.

                  if not available ls_mstr then do:

                     create ls_mstr.
                     assign
                        ls_addr = input shop_site
                        ls_type = "suppcal".
                  end.

                  create shop_cal.
                  assign
                     shop_site
                     shop_wkctr = ""
                     shop_mch = ""
                     shop_wdays[1] = no
                     shop_wdays[2] = yes
                     shop_wdays[3] = yes
                     shop_wdays[4] = yes
                     shop_wdays[5] = yes
                     shop_wdays[6] = yes
                     shop_wdays[7] = no
                     shop_hours[1] = 0
                     shop_hours[2] = 8
                     shop_hours[3] = 8
                     shop_hours[4] = 8
                     shop_hours[5] = 8
                     shop_hours[6] = 8
                     shop_hours[7] = 0.

               end. /* no shop_cal */

               find ad_mstr where ad_addr = shop_site no-lock no-error.

               display
                  shop_site
                  ad_name when (available ad_mstr)
                  "" when (not available ad_mstr) @ ad_name
                  shop_wdays
                  shop_hours
               with frame a.

               ststatus = stline[2].
               status input ststatus.

               do on error undo, retry with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.


                  del-yn = no.

                  set shop_wdays shop_hours go-on ("F5" "CTRL-D").

                  if lastkey = keycode("F5")
                  or lastkey = keycode("CTRL-D")
                  then do:

                     del-yn = yes.
                     {mfmsg01.i 11 1 del-yn}
                     if not del-yn then undo , retry.

                     if del-yn then do:

/*GM48*/                for each cal_det exclusive-lock where
                                 cal_site = shop_site
                             and cal_wkctr = shop_wkctr
                             and cal_mch = shop_mch:
                           delete cal_det.
                        end.

                        find first ls_mstr where
                                   ls_type = "suppcal"
                               and ls_addr = shop_site
                        exclusive-lock.

                        delete ls_mstr.
                        delete shop_cal.
                        clear frame a.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
                        del-yn = no.
                        next mainloop.

                     end.

                  end.

               end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* frame a */

/*J3BR*/       b-loop:
               repeat with frame b:
/*GUI*/ if global-beam-me-up then undo, leave.


                  prompt-for cal_ref cal_start with frame b editing:
                     {mfnp05.i cal_det cal_det "cal_site = shop_site and
                       cal_wkctr = shop_wkctr and cal_mch = shop_mch"
                       cal_ref "input cal_ref"}
                     if recno <> ? then
                     display
                        cal_ref
                        cal_start
                        cal_end
                        cal_hours.
                  end.

                  find cal_det using cal_ref and cal_start
                  where cal_site = shop_site
                  and cal_wkctr = shop_wkctr and cal_mch = shop_mch no-error.

                  if not available cal_det then do:
                     {mfmsg.i 1 1}
                     create cal_det.
                     assign
                        cal_ref
                        cal_start
                        cal_site = shop_site
                        cal_wkctr = shop_wkctr
                        cal_mch = shop_mch.
                  end.

                  recno = recid(cal_det).

                  display
                     cal_ref
                     cal_start
                     cal_end
                     cal_hours.

                  ststatus = stline[2].
                  status input ststatus.

                  do on error undo , retry:
/*GUI*/ if global-beam-me-up then undo, leave.


                     del-yn = no.

                     set cal_end cal_hours go-on ("F5" "CTRL-D").

                     if lastkey = keycode("F5")
                     or lastkey = keycode("CTRL-D")
                     then do:

                        del-yn = yes.
                        {mfmsg01.i 11 1 del-yn}
                        if not del-yn then undo , retry.

                        if del-yn then do:
                           delete cal_det.
                           clear frame b.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.
                           del-yn = no.
                        end.

                     end.
/*J3BR*/             else do:
/*J3BR*/                if cal_start <> ? and
/*J3BR*/                   cal_end   <> ? and
/*J3BR*/                   cal_start > cal_end
/*J3BR*/                then do:
/*J3BR*/                   /* START DATE MUST BE PRIOR TO END DATE  */
/*J3BR*/                   {mfmsg.i 4 3}
/*J3BR*/                   next-prompt cal_start.
/*J3BR*/                   if batchrun = yes then
/*J3BR*/                      undo b-loop, leave b-loop.
/*J3BR*/                   else
/*J3BR*/                      undo b-loop, retry b-loop.
/*J3BR*/                end. /* IF CAL_START <> ? ... */
/*J3BR*/             end. /* ELSE DO */

                  end.
/*GUI*/ if global-beam-me-up then undo, leave.


               end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* repeat b */

/*G1R2*/       framecloop:
               repeat with frame c:
/*GUI*/ if global-beam-me-up then undo, leave.


                  prompt-for hd_date with frame c editing:

                     /* FIND NEXT/PREVIOUS RECORD */
                     {mfnp05.i hd_mstr hd_mstr "hd_site = shop_site"
                       hd_date "input hd_date"}

                     if recno <> ? then
                     display
                        hd_date
                        string(entry(weekday(hd_date),
/*H1DK*                 "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,   */
/*H1DK*                  Saturday" )) @ daylabel no-label                   */
/*N0RT* /*H1DK*/        {&rsscmt_p_5} )) @ daylabel no-label */
/*N0RT*/                days)) @ daylabel no-label
                        hd_desc.
                  end.

                  /* ADD/MOD/DELETE */
                  find hd_mstr where hd_site = shop_site
                  and hd_date = input hd_date
                  exclusive-lock no-error.

                  if not available hd_mstr then do:
                     create hd_mstr.
                     assign
                        hd_site = shop_site
                        hd_date.
                  end.

                  display
/*N0RT*              string(entry(weekday(hd_date),{&rsscmt_p_5} )) */
/*N0RT*/             string(entry(weekday(hd_date),days))
                     @ daylabel no-label
                     hd_desc.

                  ststatus = stline[2].
                  status input ststatus.

                  do on error undo, retry with frame c:
/*GUI*/ if global-beam-me-up then undo, leave.


                     del-yn = no.

                     set hd_desc go-on ("F5" "CTRL-D" ).

                     if lastkey = keycode("F5")
                     or lastkey = keycode("CTRL-D")
                     then do:

                        del-yn = yes.
                        {mfmsg01.i 11 1 del-yn}
                        if not del-yn then undo, retry.

                        if del-yn or hd_date = ? then do:
                           delete hd_mstr.
/*G1R2*/                   display
/*G1R2*/                      "" @ hd_date
/*G1R2*/                      "" @ hd_desc
/*G1R2*/                      "" @ daylabel no-label
/*G1R2*/                   with frame c.
/*G1R2*                    clear frame c. */
                           del-yn = no.
/*G1R2*                    up 1. */
/*G1R2*/                   next framecloop.
/*G1R2*                    next mainloop. */
                        end.

                     end.

                  end.
/*GUI*/ if global-beam-me-up then undo, leave.


               end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* repeat c */

            end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* transaction */

/*G0D5*/    /* TURN ON SCHEDULE CHANGE FLAG FOR REQUIRED SCHEDULE UPDATE
             * WHENEVER SUPPLIER CALENDAR MAINTENANCE HAS BEEN USED. */
/*G0D5*/    for each po_mstr where po_vend = shop_site and po_sched no-lock:
/*G0D5*/       do transaction:
/*G0D5*/          for each pod_det where pod_nbr = po_nbr
/*G0D5*/          and pod_sched_chgd = no no-lock:
/*G0D5*/             find poddet where recid(poddet) = recid(pod_det)
/*G0D5*/             exclusive-lock no-error.
/*G0D5*/             if available poddet then
/*G0D5*/                poddet.pod_sched_chgd = yes.
/*G0D5*/          end.
/*G0D5*/       end.
/*G0D5*/    end.

         end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* mainloop repeat */

         status input.
